package com.cloudpivot.receivales;

import com.cloudpivot.receivales.contract.service.http.HttpAPIServiceForCrm;
import com.cloudpivot.receivales.contract.util.StrUtil;
import com.cloudpivot.receivales.crm.service.WeeklyCountServiceImpl;
import com.cloudpivot.receivales.util.DingMessageUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;

@SpringBootTest
class CloudpivotApplicationTest3 {

    @Autowired
    private DingMessageUtil dingMessageUtil;

    @Autowired
    private WeeklyCountServiceImpl weeklyCountService;


    /**
     * dingding msg测试
     */
    @Test
    public void interfaceTest() {
        dingMessageUtil.pushMessage(null,"合同同步测试");
    }

    /**
     * 获取合同编号测试
     */
    @Test
    public void interfaceTest1() {
        String id="E64A8268-10C3-E911-80D8-0050569A1EAB";
        String start = "2022-01-01 00:00:00";
        String end="2022-01-31 23:59:59";
        weeklyCountService.getList(id,start,end);

    }

    @Test
    public void interfaceTest3(){
        String date_str="2022-02-02 00:00:00";
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            Calendar cale = Calendar.getInstance();
            cale.setTime(formatter.parse(date_str));
            cale.add(Calendar.MONTH, 0);
            cale.set(Calendar.DAY_OF_MONTH, 1);
            System.out.println(formatter.format(cale.getTime()) + " 00:00:00");
            cale.add(Calendar.MONTH, 1);
            cale.set(Calendar.DAY_OF_MONTH, 0);
            System.out.println(formatter.format(cale.getTime()) + " 23:59:59");
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
